package com.fita.wechat.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.fita.entity.agent.Agent;
import com.fita.entity.order.Order;
import com.fita.entity.order.OrderDetails;
import com.fita.entity.order.OrderStatus;

/**
 * 
 * @author 宋剑宏
 *
 */
@Dao("hibernate")
public interface OrderDao {

	/**
	 * 根据状态查询订单
	 * 
	 * @param status
	 * @return
	 */
	@Query("FROM Order WHERE status = :status AND disabled = false")
	public List<Order> listOrder(@Variable("status") OrderStatus status);

	/**
	 * @param agent
	 * @param status
	 * @return
	 */
	@Query("FROM Order WHERE status = :status AND disabled = false AND agent = :agent ORDER BY createTime DESC ")
	public List<Order> list(@Variable("agent") Agent agent, @Variable("status") OrderStatus status);

	/**
	 * @param agent
	 * @param orderStatus
	 * @return
	 */
	@Query("FROM Order WHERE status IN (:orderStatus) AND disabled = false AND agent = :agent ORDER BY createTime DESC ")
	public List<Order> list(@Variable("agent") Agent agent, @Variable("orderStatus") OrderStatus[] orderStatus);
	
	/**
	 * 
	 * @param order
	 * @return
	 */
	@Query("FROM OrderDetails WHERE disabled = false AND order = :order")
	public OrderDetails load(@Variable("order") Order order);
}
